A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d3/d4c/xor__cipher_8cpp_source.html below:

TheAlgorithms/C++: ciphers/xor_cipher.cpp Source File

Go to the documentation of this file. 47

std::string

encrypt

(

const

std::string &text,

const int

&key) {

48

std::string encrypted_text =

""

;

49 for

(

auto

&c: text) {

50 char

encrypted_char = char(c ^ key);

51

encrypted_text += encrypted_char;

53 return

encrypted_text;

61

std::string

decrypt

(

const

std::string &text,

const int

&key) {

62

std::string decrypted_text =

""

;

63 for

(

auto

&c : text) {

64 char

decrypted_char = char(c ^ key);

65

decrypted_text += decrypted_char;

67 return

decrypted_text;

77

std::string text1 =

"Whipalsh! : Do watch this movie..."

;

80

assert(text1 == decrypted1);

81

std::cout <<

"Original text : "

<< text1;

82

std::cout <<

" , Encrypted text (with key = 17) : "

<< encrypted1;

83

std::cout <<

" , Decrypted text : "

<< decrypted1 << std::endl;

85

std::string text2 =

"->Valar M0rghulis<-"

;

88

assert(text2 == decrypted2);

89

std::cout <<

"Original text : "

<< text2;

90

std::cout <<

" , Encrypted text (with key = 29) : "

<< encrypted2;

91

std::cout <<

" , Decrypted text : "

<< decrypted2 << std::endl;

Functions for XOR cipher algorithm.

Algorithms for encryption and decryption.

std::string decrypt(const std::string &text, const int &key)

std::string encrypt(const std::string &text, const int &key)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4