Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » operation with ascii table character (Pascal x C++/U++)
Re: operation with ascii table character (Pascal x C++/U++) [message #56825 is a reply to message #56799] Sun, 18 April 2021 00:12 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 203
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

I thank you all very much. The routine was this low, of simple encryption. To decrypt the function is the same. The issue of content resulting from encryption does not need to be displayed (internally the contents are stored, for example in the database) and when decrypting the content recovery, it is correct and logically visible. Only that the function can be improved, but it is a my start.

"mStr" is content you want to encrypt
"mchave" is encryption key content

                          
String Criptografia(String mStr, String mChave)
{
  String s;
  int pos,posLetra;
  mChave=mChave;
  int TamanhoString = mStr.GetLength();
  int TamanhoChave = mChave.GetLength();

  for(int i = 0; i < TamanhoString; i++){
    pos = (i % TamanhoChave);  
    
    if( pos == 0)
      pos = TamanhoChave;
    
    int a = mStr[i];
    int b = mChave[pos];
    
    posLetra = a ^ b;

    if (posLetra == 0)
      posLetra = mStr[i];
    s << char(posLetra);
  }
  return s;
}


CONSOLE_APP_MAIN
{
	//first time you encripts
	String a=Criptografia("José da Silva","efg");
	//second time you decrips
	String b=Criptografia(a,"efg");
        Cout()<< b << EOL;	
}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GLCtrl Linux dependency
Next Topic: Deprecated code
Goto Forum:
  


Current Time: Sat Apr 27 03:33:46 CEST 2024

Total time taken to generate the page: 0.02690 seconds