首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

crypto/subtle

  • import "crypto/subtle"
  • 概述
  • 索引

概述

Subtle 包实现了在密码学中经常使用的功能,但需要仔细考虑才能正确使用。

索引

  • func ConstantTimeByteEq(x, y uint8) int
  • func ConstantTimeCompare(x, y []byte) int
  • func ConstantTimeCopy(v int, x, y []byte)
  • func ConstantTimeEq(x, y int32) int
  • func ConstantTimeLessOrEq(x, y int) int
  • func ConstantTimeSelect(v, x, y int) int

文件包

func ConstantTimeByteEq(查看源代码)

代码语言:javascript
复制
func ConstantTimeByteEq(x, y uint8) int

如果 x == y 则 ConstantTimeByteEq 返回1,否则返回0。

func ConstantTimeCompare(查看源代码)

代码语言:javascript
复制
func ConstantTimeCompare(x, y []byte) int

当且仅当两个切片 x和y 具有相等的内容时,ConstantTimeCompare 返回1。所花费的时间是切片长度的函数,并且与内容无关。

func ConstantTimeCopy(查看源代码)

代码语言:javascript
复制
func ConstantTimeCopy(v int, x, y []byte)

如果v == 1,ConstantTimeCopy 将y的内容复制到x(一个等长的片段)中。如果v == 0,x保持不变。如果v取任何其他值,它的行为是不确定的。

func ConstantTimeEq(查看源代码)

代码语言:javascript
复制
func ConstantTimeEq(x, y int32) int

如果x == y,则ConstantTimeEq 返回1,否则返回0。

func ConstantTimeLessOrEq(查看源代码)

代码语言:javascript
复制
func ConstantTimeLessOrEq(x, y int) int

如果x <= y,则ConstantTimeLessOrEq 返回1,否则返回0。如果x或y为负值或> 2**31 - 1,则其行为不确定。

func ConstantTimeSelect(查看源代码)

代码语言:javascript
复制
func ConstantTimeSelect(v, x, y int) int

如果v为1,则ConstantTimeSelect 返回x;如果v为0,则返回y。如果v采用任何其他值,则其行为是不确定的。

扫码关注腾讯云开发者

领取腾讯云代金券