小编sha*_*cal的帖子

在解密程序中使用负数取模时出现问题

我对 C 相当陌生,最近一直致力于制作一个简单的加密/解密程序。我设法很好地进行了加密,但在解密方面遇到了障碍。

相关代码如下:

加密(其中 asciinum 是字母的 ascii 值,k 是要移动的“vigenere”密钥)。

//shifts lowercase letters by key
    if (asciinum >= 97 && asciinum <= 123)
    {
        f = p % keylen;
        k = key[f];
        asciinum = (asciinum - 97) + k;
        asciinum = (asciinum % 26) + 97;
        letterc = (char) asciinum;
        //printf("%c\n", letterc);
        cipher[j] = letterc;
        p++;
    }

    //shifts uppercase letters by key
    if (asciinum >= 65 && asciinum <= 91)
    {
        f = p % keylen;
        k = key[f];
        asciinum …
Run Code Online (Sandbox Code Playgroud)

c encryption

2
推荐指数
1
解决办法
1690
查看次数

标签 统计

c ×1

encryption ×1