Produced by Araxis Merge on 10/26/2017 10:44:23 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Oct 27 02:44:23 2017 UTC | ||
| 2 | OSCIF_BMS_v2_iter 2_September_2017.zip\BMS_Cand\Source\Sources\BMS.Vista.TestEis\BMS.Utils | SecureStringUtils.cs | Wed Oct 18 18:47:02 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 55 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | using Syst em; | |||||
| 2 | using Syst em.Collect ions.Gener ic; | |||||
| 3 | using Syst em.Linq; | |||||
| 4 | using Syst em.Text; | |||||
| 5 | using Syst em.Securit y; | |||||
| 6 | using Syst em.Runtime .InteropSe rvices; | |||||
| 7 | ||||||
| 8 | namespace BMS.Utils | |||||
| 9 | { | |||||
| 10 | public static cl ass Secure StringUtil s | |||||
| 11 | { | |||||
| 12 | // Usage: | |||||
| 13 | // string pas sword = "S ecretPassw ord"; | |||||
| 14 | // SecureStri ng secureP assword = password.C onvertToSe cureString (); | |||||
| 15 | // string pas sword2 = s ecurePassw ord.Conver tToUnsecur eString(); | |||||
| 16 | ||||||
| 17 | pu blic stati c string C onvertToUn secureStri ng(this Se cureString secureStr ) | |||||
| 18 | { | |||||
| 19 | if (secu reStr == n ull) | |||||
| 20 | retu rn null; | |||||
| 21 | ||||||
| 22 | IntPtr u nmanagedSt ring = Int Ptr.Zero; | |||||
| 23 | ||||||
| 24 | try | |||||
| 25 | { | |||||
| 26 | unma nagedStrin g = Marsha l.SecureSt ringToGlob alAllocUni code(secur eStr); | |||||
| 27 | char [] newStri ng = new c har[secure Str.Length ]; | |||||
| 28 | for (Int32 i = 0; i < se cureStr.Le ngth; i++) | |||||
| 29 | { | |||||
| 30 | newString[ i] = (Char )Marshal.R eadInt16(u nmanagedSt ring, i * 2); | |||||
| 31 | } | |||||
| 32 | ||||||
| 33 | retu rn new str ing(newStr ing); | |||||
| 34 | } | |||||
| 35 | finally | |||||
| 36 | { | |||||
| 37 | Mars hal.ZeroFr eeGlobalAl locUnicode (unmanaged String); | |||||
| 38 | } | |||||
| 39 | } | |||||
| 40 | ||||||
| 41 | pu blic stati c SecureSt ring Conve rtToSecure String(thi s string u nsecureStr ) | |||||
| 42 | { | |||||
| 43 | if (unse cureStr == null) | |||||
| 44 | retu rn null; | |||||
| 45 | ||||||
| 46 | SecureSt ring secur eStr = new SecureStr ing(); | |||||
| 47 | for (int i = 0; i < unsecure Str.Length ; i++) | |||||
| 48 | { | |||||
| 49 | secu reStr.Appe ndChar(uns ecureStr[i ]); | |||||
| 50 | } | |||||
| 51 | secureSt r.MakeRead Only(); | |||||
| 52 | return s ecureStr; | |||||
| 53 | } | |||||
| 54 | } | |||||
| 55 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.