File tree Expand file tree Collapse file tree 1 file changed +2
-18
lines changed
src/DwFramework.Core/Extensions Expand file tree Collapse file tree 1 file changed +2
-18
lines changed Original file line number Diff line number Diff line change @@ -180,30 +180,14 @@ public static byte[] FromBase64String(this string base64String)
180180 /// </summary>
181181 /// <param name="bytes"></param>
182182 /// <returns></returns>
183- public static string ToHex ( this byte [ ] bytes )
184- {
185- var builder = new StringBuilder ( ) ;
186- for ( var i = 0 ; i < bytes . Length ; i ++ )
187- {
188- builder . Append ( bytes [ i ] . ToString ( "x2" ) ) ;
189- }
190- return builder . ToString ( ) ;
191- }
183+ public static string ToHex ( this byte [ ] bytes ) => Convert . ToHexString ( bytes ) ;
192184
193185 /// <summary>
194186 /// Hex转字节数组
195187 /// </summary>
196188 /// <param name="hexString"></param>
197189 /// <returns></returns>
198- public static byte [ ] FromHex ( this string hexString )
199- {
200- var bytes = new byte [ hexString . Length / 2 ] ;
201- for ( var i = 0 ; i < bytes . Length ; i ++ )
202- {
203- bytes [ i ] = ( byte ) Convert . ToInt32 ( hexString . Substring ( i * 2 , 2 ) , 16 ) ;
204- }
205- return bytes ;
206- }
190+ public static byte [ ] FromHex ( this string hexString ) => Convert . FromHexString ( hexString ) ;
207191
208192 /// <summary>
209193 /// 是否为中文字符
You can’t perform that action at this time.
0 commit comments