Post: [C# and Python] Old School Encryption
04-14-2011, 08:50 PM #1
schnzrs
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); Here are some examples of very basic cryptography in C# and Python. Back in the old days, crypters usually just had value shifts. Like A -> B, B -> C, C-> D, and so on. These example are just an idea of how to make your own encrypters and decrypters. You can improve this code a lot, since I am showing only showing a "skeleton" of an encrypter. Some ways to improve it is to shift value by the length of the string and adding random characters.

C#
    static string encrypt(string input){
string output = "";
foreach (char i in input){
int iVal = (int)i + 1;
output += (char)iVal;
}
return output;
}

static string decrypt(string input){
string output = "";
foreach (char i in input){
int iVal = (int)i - 1;
output += (char)iVal;
}
return output;
}


Python:
    def encrypt(input):
output = "";
for i in input:
iVal = ord(i) + 1
output += chr(iVal)
return output

def decrypt(input):
output = "";
for i in input:
iVal = ord(i) - 1
output += chr(iVal)
return output

The following user thanked schnzrs for this useful post:

Outlasted Wolf

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo