본문 바로가기

C#/String | Byte | Int

(4)
C# byte 압축 / 해제 C# byte 압축 / 해제 // byte 압축하기 byte[] originByte; byte[] compressedByte; using (MemoryStream ms = new MemoryStream()) { using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress)) { ds.Write(originByte, 0, originByte.Length); } compressedByte = ms.ToArray(); } // byte 압축풀기 byte[] originByte; byte[] deCompressedByte; using (MemoryStream ms = new MemoryStream(compressedByte)) { using ..
C# Byte Array에 Byte Array 합치기 C# Byte Array에 Byte Array 합치기 Byte array / Add / Combine / Sum private static byte[] Combine(byte[] first, byte[] second) { byte[] ret = new byte[first.Length + second.Length]; Buffer.BlockCopy(first, 0, ret, 0, first.Length); Buffer.BlockCopy(second, 0, ret, first.Length, second.Length); return ret; }
C# Byte Array Compare 바이트 비교 C# Byte Array Compare 바이트 비교 [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] static extern int memcmp(byte[] b1, byte[] b2, long count); static bool ByteArrayCompare(byte[] b1, byte[] b2) { if (b1 == null || b2 == null) { return false; } // Validate buffers are the same length. // This also ensures that the count does not exceed the length of either buffer. return b1.Lengt..
C# 난수 생성 C# 난수 생성 방법1. #region 구글에서 사용하는 난수문자 public static string GenerateCode(uint id) { return ToBase62(PermuteId(id)); } private static double RoundFunction(uint input) { // Must be a function in the mathematical sense (x=y implies f(x)=f(y)) // but it doesn't have to be reversible. // Must return a value between 0 and 1 return ((1369 * input + 150889) % 714025) / 714025.0; } private static uint Perm..