Bruteforce Caesar Cipher

0

两个版本:c++和python。

c++实现如下:

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
    string str = "U8Y]:8KdJHTXRI>XU#?!K_ecJH]kJG*bRH7YJH7YSH]*=93dVZ3^S8*$:8\"&:9U]RH;g=8Y!U92'=j*$KH]ZSj&[S#!gU#*dK9\\.";
    string temp = str;
    for( int n = -127 ; n < 127 ; n++ )
    {
        for( int i = 0 ; i < 100 ; i++ )
        {
            temp[i]= str[i]+ n;
        }
        cout << temp << endl;
    }
    return 0;
}

Python实现如下:

#!/usr/bin/python

lstr="""U8Y]:8KdJHTXRI>XU#?!K_ecJH]kJG*bRH7YJH7YSH]*=93dVZ3^S8*$:8"&:9U]RH;g=8Y!U92'=j*$KH]ZSj&[S#!gU#*dK9\."""  
  
for p in range(127):  
    str1 = ''  
    for i in lstr:  
        temp = chr((ord(i)+p)%127)  
        if 32<ord(temp)<127 :  
            str1 = str1 + temp   
            feel = 1  
        else:  
            feel = 0  
            break  
    if feel == 1:  
        print(str1)

Leave A Reply

苏ICP备16066660号-1

苏公网安备 32011502010432号