Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public void ValidationUserInfo(string userName,string password)
  2. {
  3. //Do validations with password, after converting it to secureString and fetch it out?....
  4.  
  5. //Just clear the memory!
  6. ClearSensiveString(password);
  7.  
  8. //Do any others or return after validations.....
  9. }
  10.  
  11. //Your memory clear way:
  12.  
  13. static unsafe void ClearSensiveString(string sensiveValue,char coverChar='')
  14. {
  15. fixed(char* c = sensiveValue)
  16. {
  17. for (int i = 0; i < sensiveValue.Length; i++)
  18. {
  19. c[i] = coverChar;
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement