Ejemplo n.º 1
0
// Decode returns the decoded form of src. The returned slice may be a sub-
// slice of dst if dst was large enough to hold the entire decoded block.
// Otherwise, a newly allocated slice will be returned.
// It is valid to pass a nil dst.
func Decode(dst, src []byte) ([]byte, error) {
	dLen, s, err := decodedLen(src)
	if err != nil {
		return nil, err
	}

	if dLen == 0 {
		if len(src) == 1 {
			return nil, nil
		}

		return nil, ErrCorrupt
	}

	if len(dst) < dLen {
		dst = make([]byte, dLen)
	}

	d := int(C.decode(C.int(s), C.int(len(src)), (*C.uint8_t)(&src[0]), C.int(len(dst)), (*C.uint8_t)(&dst[0])))
	if d != dLen {
		return nil, ErrCorrupt
	}

	return dst[:d], nil

}
Ejemplo n.º 2
0
// Decode returns the decoded form of src. The returned slice may be a sub-
// slice of buf if buf was large enough to hold the entire decoded block.
// Otherwise, a newly allocated slice will be returned.
// It is valid to pass a nil buf.
func Decode(buf, src []byte) ([]byte, error) {
	dLen, s, err := decodedLen(src)
	if err != nil {
		return nil, err
	}

	if dLen == 0 {
		if len(src) == 1 {
			return nil, nil
		}

		return nil, ErrCorrupt
	}

	if len(buf) < dLen {
		buf = *buffer.Get(dLen)
	}

	d := int(C.decode(C.int(s), C.int(len(src)), (*C.uint8_t)(&src[0]), C.int(len(buf)), (*C.uint8_t)(&buf[0])))
	if d != dLen {
		return nil, ErrCorrupt
	}

	return buf[:d], nil
}
Ejemplo n.º 3
0
func IsPassedAuth() bool {
	err := C.decode()
	//PrintOrigRandom()
	//PrintAlpuPlainText()
	//PrintAlpuCipherText()

	fmt.Println("IsPassedAuth", err)
	if err == 0 {
		return true
	}
	return false
}