Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Posix;
- //valac --pkg=posix xor.vala
- static uint key = 123;
- char[] string_to_char_array(string str) {
- char[] char_array = new char[str.length];
- for (int i = 0; i < str.length; i++){
- char_array[i] = (char)str.get_char(str.index_of_nth_char(i));
- }
- return char_array;
- }
- public static string XOR_EncryptDecrypt(string str)
- {
- char[] f = string_to_char_array(str);
- for (int i = 0; i < f.length; i++)
- {
- f[i] = (char)((uint)f[i] ^ key);
- }
- string result = (string)f;
- return result;
- }
- void main()
- {
- string to_enc = "a";
- string enc = XOR_EncryptDecrypt(to_enc);
- print("%s", enc);
- system("echo "+enc+" > aaa.txt"); //just to throw it into an archive
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement