SecureStringToGlobalAllocUnicode() 공개 정적인 메소드

public static SecureStringToGlobalAllocUnicode ( SecureString s ) : IntPtr
s SecureString
리턴 IntPtr
예제 #1
0
        public static string ToRawString(this SecureString sstr)
        {
            IntPtr valuePtr = IntPtr.Zero;

            try {
                valuePtr = SecureStringMarshal.SecureStringToGlobalAllocUnicode(sstr);
                return(Marshal.PtrToStringUni(valuePtr));
            } finally {
                Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
            }
        }
        public static string ToUnsecureString(this SecureString str)
        {
            if (str == null)
            {
                return(null);
            }

            var unmanagedStr = IntPtr.Zero;

            try
            {
                unmanagedStr = SecureStringMarshal.SecureStringToGlobalAllocUnicode(str);
                return(Marshal.PtrToStringUni(unmanagedStr));
            }
            finally
            {
                Marshal.ZeroFreeGlobalAllocUnicode(unmanagedStr);
            }
        }