當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Int.Text方法代碼示例

本文整理匯總了Golang中math/big.Int.Text方法的典型用法代碼示例。如果您正苦於以下問題:Golang Int.Text方法的具體用法?Golang Int.Text怎麽用?Golang Int.Text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在math/big.Int的用法示例。


在下文中一共展示了Int.Text方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewID

// NewID generates a new identifier for use where random identifiers with low
// collision probability are required.
//
// With the parameters in this package, the generated identifier will provide
// 128 bits of entropy encoded with base36. Leading padding is added if the
// string is less 25 bytes. We do not intend to maintain this interface, so
// identifiers should be treated opaquely.
func NewID() string {
	var p [randomIDEntropyBytes]byte

	if _, err := io.ReadFull(idReader, p[:]); err != nil {
		panic(fmt.Errorf("failed to read random bytes: %v", err))
	}

	var nn big.Int
	nn.SetBytes(p[:])
	return fmt.Sprintf("%0[1]*s", maxRandomIDLength, nn.Text(randomIDBase))
}
開發者ID:amitshukla,項目名稱:docker,代碼行數:18,代碼來源:randomid.go

示例2: getCAHashFromToken

func getCAHashFromToken(token string) (digest.Digest, error) {
	split := strings.Split(token, "-")
	if len(split) != 4 || split[0] != "SWMTKN" || split[1] != "1" {
		return "", errors.New("invalid join token")
	}

	var digestInt big.Int
	digestInt.SetString(split[2], joinTokenBase)

	return digest.ParseDigest(fmt.Sprintf("sha256:%0[1]*s", 64, digestInt.Text(16)))
}
開發者ID:CWSpear,項目名稱:docker,代碼行數:11,代碼來源:config.go

示例3: generateRandomSecret

func generateRandomSecret() string {
	var secretBytes [generatedSecretEntropyBytes]byte

	if _, err := cryptorand.Read(secretBytes[:]); err != nil {
		panic(fmt.Errorf("failed to read random bytes: %v", err))
	}

	var nn big.Int
	nn.SetBytes(secretBytes[:])
	return fmt.Sprintf("%0[1]*s", maxGeneratedSecretLength, nn.Text(generatedSecretBase))
}
開發者ID:CrocdileChan,項目名稱:docker,代碼行數:11,代碼來源:secret.go

示例4: GenerateJoinToken

// GenerateJoinToken creates a new join token.
func GenerateJoinToken(rootCA *RootCA) string {
	var secretBytes [generatedSecretEntropyBytes]byte

	if _, err := cryptorand.Read(secretBytes[:]); err != nil {
		panic(fmt.Errorf("failed to read random bytes: %v", err))
	}

	var nn, digest big.Int
	nn.SetBytes(secretBytes[:])
	digest.SetString(rootCA.Digest.Hex(), 16)
	return fmt.Sprintf("SWMTKN-1-%0[1]*s-%0[3]*s", base36DigestLen, digest.Text(joinTokenBase), maxGeneratedSecretLength, nn.Text(joinTokenBase))
}
開發者ID:yongtang,項目名稱:swarmkit,代碼行數:13,代碼來源:config.go

示例5: checkResult

func checkResult(t test, expr, key string, r *big.Int) {
	if t.Values[key].Cmp(r) != 0 {
		fmt.Fprintf(os.Stderr, "Line %d: %s did not match %s.\n\tGot %s\n", t.LineNumber, expr, key, r.Text(16))
	}
}
開發者ID:onedata,項目名稱:helpers,代碼行數:5,代碼來源:check_bn_tests.go

示例6: buildPrivateKeyPath

func (c *VFSCAStore) buildPrivateKeyPath(id string, serial *big.Int) vfs.Path {
	return c.basedir.Join("private", id, serial.Text(10)+".key")
}
開發者ID:crohling,項目名稱:kops,代碼行數:3,代碼來源:vfs_castore.go

示例7: buildCertificatePath

func (c *VFSCAStore) buildCertificatePath(id string, serial *big.Int) vfs.Path {
	return c.basedir.Join("issued", id, serial.Text(10)+".crt")
}
開發者ID:crohling,項目名稱:kops,代碼行數:3,代碼來源:vfs_castore.go


注:本文中的math/big.Int.Text方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。