gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
func X19HttpEncrypt(bodyIn []byte) ([]byte, error) { body := make([]byte,…
- User
func X19HttpEncrypt(bodyIn []byte) ([]byte, error) { body := make([]byte, int(math.Ceil(float64(len(bodyIn)+16)/16))*16) copy(body, bodyIn) randFill := []byte(RandStringRunes(0x10)) for i := 0; i < len(randFill); i++ { body[i+len(bodyIn)] = randFill[i] }
keyQuery := byte(rand.Intn(15))<<4 | 2 initVector := []byte(RandStringRunes(0x10)) encrypted, err := AES_CBC_Encrypt(X19PickKey(keyQuery), body, initVector) if err != nil { return nil, err } result := make([]byte, 16 /* iv */ +len(encrypted) /* encrypted (body + scissor) */ +1 /* key query */) for i := 0; i < 16; i++ { result[i] = initVector[i] } for i := 0; i < len(encrypted); i++ { result[i+16] = encrypted[i] } result[len(result)-1] = keyQuery return result, nil}转换成C#
- Assistant
func X19HttpEncrypt(bodyIn []byte) ([]byte, error) { body := new byte[(int)Math.Ceiling((double)(bodyIn.Length + 16)/16)*16]; Array.Copy(bodyIn, body, bodyIn.Length); byte[] randFill = Encoding.ASCII.GetBytes(RandStringRunes(0x10)); for (int i = 0; i < randFill.Length; i++) { body[i+bodyIn.Length] = randFill[i]; }
byte keyQuery = (byte)(new Random().Next(0, 15) << 4 | 2); byte[] initVector = Encoding.ASCII.GetBytes(RandStringRunes(0x10)); byte[] encrypted; try { encrypted = AES_CBC_Encrypt(X19PickKey(keyQuery), body, initVector); } catch (Exception ex) { return null, ex; } byte[] result = new byte[16 /* iv */ +encrypted.Length /* encrypted (body + scissor) */ +1 /* key query */]; for (int i = 0; i < 16; i++) { result[i] = initVector[i]; } for (int i = 0; i < encrypted.Length; i++) { result[i+16] = encrypted[i]; } result[result.Length-1] = keyQuery; return result;}