• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang utils.B58encode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/repbin/repbin/utils.B58encode函数的典型用法代码示例。如果您正苦于以下问题:Golang B58encode函数的具体用法?Golang B58encode怎么用?Golang B58encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了B58encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Encode

// Encode an expireStruct
func (es ExpireStruct) Encode() ExpireStructEncoded {
	out := make([]byte, 0, ExpireStructSize)
	out = append(out, []byte(strconv.FormatUint(es.ExpireTime, 10)+" ")...)
	out = append(out, []byte(utils.B58encode(es.MessageID[:])+" ")...)
	out = append(out, []byte(utils.B58encode(es.SignerPubKey[:])+" ")...)
	return out[:len(out)]
}
开发者ID:carriercomm,项目名称:repbin,代码行数:8,代码来源:expirestruct.go


示例2: ServeID

// ServeID returns server information.
func (ms MessageServer) ServeID(w http.ResponseWriter, r *http.Request) {
	ms.RandomSleep()
	now := CurrentTime() + ms.TimeSkew
	privK := [32]byte(*ms.authPrivKey)
	_, pubkey, challenge := keyauth.GenTempKeyTime(uint64(now), &privK)
	info := &ServerInfo{
		Time:            now,
		AuthPubKey:      utils.B58encode(pubkey[:]),
		AuthChallenge:   utils.B58encode(challenge[:]),
		MaxPostSize:     int64(messagestore.MaxMessageSize),
		MinPostSize:     ms.InfoStruct.MinPostSize,
		MinHashCashBits: ms.InfoStruct.MinHashCashBits,
	}
	if ms.EnablePeerHandler {
		info.Peers = ms.getPeerURLs()
	}
	ms.RandomSleep()
	w.Header().Set("Content-Type", "text/json")
	b, err := json.Marshal(info)
	if err != nil {
		log.Debugf("Info: %s\n", err)
	}
	w.Write(b)
	w.Write([]byte("\n"))
	return
}
开发者ID:RoPe93,项目名称:repbin,代码行数:27,代码来源:server.go


示例3: ExpireFromIndex

// ExpireFromIndex reads the expire index and expires messages as they are recorded
func (store Store) ExpireFromIndex() {
	// ExpireRun
	delMessages, err := store.db.SelectMessageExpire(CurrentTime())
	if err != nil {
		log.Errorf("ExpireFromIndex, SelectMessageExpire: %s\n", err)
		return
	}
	for _, msg := range delMessages {
		err := store.db.DeleteBlob(&msg.MessageID)
		if err != nil {
			log.Errorf("ExpireFromIndex, DeleteBlob: %s %s\n", err, utils.B58encode(msg.MessageID[:]))
			continue
		}
		err = store.db.DeleteMessageByID(&msg.MessageID)
		if err != nil {
			log.Errorf("ExpireFromIndex, DeleteMessageByID: %s %s\n", err, utils.B58encode(msg.MessageID[:]))
		}
	}
	_, _, err = store.db.ExpireSigners(MaxAgeSigners)
	if err != nil {
		log.Errorf("ExpireFromIndex, ExpireSigners: %s\n", err)
	}
	err = store.db.ExpireMessageCounter(MaxAgeRecipients)
	if err != nil {
		log.Errorf("ExpireFromIndex, ExpireMessageCounter: %s\n", err)
	}
	err = store.db.ForgetMessages(CurrentTime() - MaxAgeRecipients)
	if err != nil {
		log.Errorf("ExpireFromIndex, ForgetMessages: %s\n", err)
	}
}
开发者ID:carriercomm,项目名称:repbin,代码行数:32,代码来源:expire.go


示例4: New

// New returns a MessageServer.
func New(driver, url, path string, pubKey, privKey []byte) (*MessageServer, error) {
	var err error
	ms := new(MessageServer)
	ms.DB = messagestore.New(driver, url, path, Workers)
	if err != nil {
		return nil, err
	}
	ms.path = path
	ms.PeerFile = path + "peers.config"
	ms.AddToPeer = DefaultAddToPeer
	ms.MaxTimeSkew = DefaultMaxTimeSkew
	ms.MinPostSize = MinPostSize
	ms.MaxPostSize = MaxPostSize
	ms.MinHashCashBits = MinHashCashBits
	ms.MaxSleep = DefaultMaxSleep
	ms.MaxIndexGlobal = DefaultIndexGlobal
	ms.MaxIndexKey = DefaultIndexKey
	ms.TimeGrace = DefaultTimeGrace
	ms.MaxAuthTokenAge = DefaultAuthTokenAge
	ms.NotifyDuration = DefaultNotifyDuration
	ms.FetchDuration = DefaultFetchDuration
	ms.FetchMax = DefaultFetchMax
	ms.ExpireDuration = DefaultExpireDuration
	ms.ExpireFSDuration = DefaultExpireFSDuration
	ms.StepLimit = DefaultStepLimit
	ms.ListenPort = DefaultListenPort
	ms.MinStoreTime = DefaultMinStoreTime
	ms.MaxStoreTime = DefaultMaxStoreTime
	ms.MaxAgeSigners = DefaultMaxAgeSigners
	ms.MaxAgeRecipients = DefaultMaxAgeRecipients
	messagestore.MaxAgeRecipients = DefaultMaxAgeRecipients
	messagestore.MaxAgeSigners = DefaultMaxAgeSigners
	ms.EnablePeerHandler = true

	ms.authPrivKey, err = message.GenLongTermKey(true, false)
	if err != nil {
		return nil, err
	}
	ms.AuthPubKey = message.GenPubKey(ms.authPrivKey)
	if pubKey != nil && privKey != nil {
		ms.TokenPubKey = new([ed25519.PublicKeySize]byte)
		ms.TokenPrivKey = new([ed25519.PrivateKeySize]byte)
		copy(ms.TokenPubKey[:], pubKey)
		copy(ms.TokenPrivKey[:], privKey)
	} else {
		ms.TokenPubKey, ms.TokenPrivKey, err = ed25519.GenerateKey(rand.Reader)
		log.Printf("Peer authentication public key: %s\n", utils.B58encode(ms.TokenPubKey[:]))
		log.Printf("Peer authentication private key: %s\n", utils.B58encode(ms.TokenPrivKey[:]))
		if err != nil {
			return nil, err
		}
	}
	ms.InfoStruct = new(ServerInfo)
	ms.InfoStruct.MinHashCashBits = ms.MinHashCashBits
	ms.InfoStruct.MinPostSize = ms.MinPostSize
	ms.InfoStruct.MaxPostSize = ms.MaxPostSize
	ms.InfoStruct.AuthPubKey = utils.B58encode(ms.AuthPubKey[:])
	return ms, nil
}
开发者ID:RoPe93,项目名称:repbin,代码行数:60,代码来源:server.go


示例5: GetNotify

// GetNotify receives notifications.
func (ms MessageServer) GetNotify(w http.ResponseWriter, r *http.Request) {
	var proof [keyproof.ProofTokenSize]byte
	w.Header().Set("Content-Type", "text/plain; charset=us-ascii")
	getValues := r.URL.Query()
	if getValues != nil {
		if v, ok := getValues["auth"]; ok {
			if len(v[0]) > keyproof.ProofTokenMax {
				io.WriteString(w, "ERROR: Bad Param\n")
				return
			}
			auth := utils.B58decode(v[0])
			if auth == nil || len(auth) > keyproof.ProofTokenSize {
				io.WriteString(w, "ERROR: Bad Param\n")
				return
			}
			copy(proof[:], auth)
			ok, timeStamp, senderPubKey := keyproof.VerifyProofToken(&proof, ms.TokenPubKey)
			if !ok {
				io.WriteString(w, "ERROR: Authentication failure\n")
				if senderPubKey == nil {
					log.Errorf("VerifyProofToken failed: (proof) %s\n", utils.B58encode(proof[:]))
				} else {
					log.Errorf("VerifyProofToken failed: (pubkey) %s\n", utils.B58encode(senderPubKey[:]))
				}
				return
			}
			// verify that we know the peer
			url := ms.PeerURL(senderPubKey)
			if url == "" {
				io.WriteString(w, "ERROR: Bad peer\n")
				log.Errorf("Notify, bad peer: %s\n", utils.B58encode(senderPubKey[:]))
				return
			}
			now := CurrentTime()
			// Test too old, too young
			if enforceTimeOuts && (now > timeStamp+DefaultAuthTokenAge+ms.MaxTimeSkew || now < timeStamp-DefaultAuthTokenAge-ms.MaxTimeSkew) {
				io.WriteString(w, "ERROR: Authentication expired\n")
				log.Errorf("VerifyProofToken replay by %s\n", url)
				return
			}
			ok, signedToken := keyproof.CounterSignToken(&proof, ms.TokenPubKey, ms.TokenPrivKey)
			if !ok {
				io.WriteString(w, "ERROR: Authentication failure\n")
				return
			}
			ms.DB.UpdatePeerAuthToken(senderPubKey, signedToken)
			log.Debugf("Notified by %s\n", url)
			io.WriteString(w, "SUCCESS: Notified\n")
			return
		}
	}
	io.WriteString(w, "ERROR: Missing Param\n")
	return
}
开发者ID:carriercomm,项目名称:repbin,代码行数:55,代码来源:notify.go


示例6: showConfig

// showConfig shows current (default) config
func showConfig() {
	if defaultSettings.PeeringPrivateKey == "" {
		pubkey, privkey, err := ed25519.GenerateKey(rand.Reader)
		if err == nil {
			defaultSettings.PeeringPrivateKey = utils.B58encode(privkey[:])
			defaultSettings.PeeringPublicKey = utils.B58encode(pubkey[:])
		}
	}
	config, _ := json.MarshalIndent(defaultSettings, "", "    ")
	fmt.Println(string(config))
}
开发者ID:mewbak,项目名称:repbin,代码行数:12,代码来源:config.go


示例7: Encode

// Encode a SignerStruct to human readable representation
func (ss SignerStruct) Encode() SignerStructEncoded {
	out := make([]byte, 0, SignerStructSize)
	out = append(out, []byte(utils.B58encode(ss.PublicKey[:])+" ")...)
	out = append(out, []byte(utils.B58encode(ss.Nonce[:])+" ")...)
	out = append(out, []byte(strconv.FormatUint(uint64(ss.Bits), 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ss.MessagesPosted, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ss.MessagesRetained, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ss.MaxMessagesPosted, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ss.MaxMessagesRetained, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ss.ExpireTarget, 10)+" ")...)
	return out[:len(out)]
}
开发者ID:carriercomm,项目名称:repbin,代码行数:13,代码来源:signerstruct.go


示例8: CmdGenKey

// CmdGenKey generates a long-term public key
func CmdGenKey() int {
	privkey, err := message.GenLongTermKey(OptionsVar.Hidden, OptionsVar.Sync)
	if err != nil {
		log.Errorf("Key generation error:%s\n", err)
		return 1
	}
	pubkey := message.GenPubKey(privkey)
	log.Dataf("STATUS (PrivateKey):\t%s\n", utils.B58encode(privkey[:]))
	// log.Dataf("STATUS (PublicKey):\t%s\n", utils.B58encode(pubkey[:]))
	log.Printf("PRIVATE key: %s\n\n", utils.B58encode(privkey[:]))
	// log.Printf("Public key: %s\n", utils.B58encode(pubkey[:]))
	_ = pubkey
	return 0
}
开发者ID:carriercomm,项目名称:repbin,代码行数:15,代码来源:genkey.go


示例9: Encode

// Encode encodes a MessageStruct in human-readable format for storage
func (ms MessageStruct) Encode() MessageStructEncoded {
	out := make([]byte, 0, MessageStructSize)
	out = append(out, []byte(strconv.FormatUint(ms.Counter, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ms.PostTime, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ms.ExpireTime, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ms.ExpireRequest, 10)+" ")...)
	out = append(out, []byte(utils.B58encode(ms.MessageID[:])+" ")...)
	out = append(out, []byte(utils.B58encode(ms.ReceiverConstantPubKey[:])+" ")...)
	out = append(out, []byte(utils.B58encode(ms.SignerPub[:])+" ")...)
	out = append(out, []byte(strconv.FormatUint(ms.Distance, 10)+" ")...)
	out = append(out, []byte(BoolToString(ms.OneTime)+" ")...)
	out = append(out, []byte(BoolToString(ms.Sync)+" ")...)
	out = append(out, []byte(BoolToString(ms.Hidden))...)
	return out[:len(out)]
}
开发者ID:carriercomm,项目名称:repbin,代码行数:16,代码来源:messagestruct.go


示例10: KeyCallBack

// KeyCallBack implements a callback function to request keys from file-descriptor
func KeyCallBack(keyMgtFd int) (*os.File, func(*message.Curve25519Key) *message.Curve25519Key) {
	knownKeys := make(map[message.Curve25519Key]message.Curve25519Key)
	fd := os.NewFile(uintptr(keyMgtFd), "fd/"+strconv.Itoa(keyMgtFd))
	return fd, func(pubkey *message.Curve25519Key) *message.Curve25519Key {
		// KeyCallBack func(*Curve25519Key) *Curve25519Key
		log.Sync()
		if v, ok := knownKeys[*pubkey]; ok { // Return from cache if we can
			return &v
		}
		b := make([]byte, 120)
		log.Dataf("STATUS (KeyMGTRequest):\t%s\n", utils.B58encode(pubkey[:]))
		log.Sync()
		n, _ := fd.Read(b)
		if n == 0 {
			log.Datas("STATUS (KeyMGT):\tREAD FAILURE\n")
			return nil
		}
		log.Datas("STATUS (KeyMGT):\tREAD DONE\n")
		k1, k2 := utils.ParseKeyPair(strings.Trim(string(b[:n]), " \t\r\n"))
		if k1 != nil {
			pub1 := message.GenPubKey(k1) // Add to cache
			knownKeys[*pub1] = *k1
		}
		if k2 != nil {
			pub2 := message.GenPubKey(k2) // Add to cache
			knownKeys[*pub2] = *k2
		}
		if v, ok := knownKeys[*pubkey]; ok { // Return from cache if we can
			return &v
		}
		return nil
	}
}
开发者ID:carriercomm,项目名称:repbin,代码行数:34,代码来源:keymgt.go


示例11: GetPeerStat

// GetPeerStat returns the last entry of peer statistics for pubkey
func (store Store) GetPeerStat(pubkey *[ed25519.PublicKeySize]byte) *structs.PeerStruct {
	st, err := store.db.SelectPeer(pubkey)
	if err != nil {
		log.Errorf("GetPeerStat: %s, %s\n", err, utils.B58encode(pubkey[:]))
		return nil
	}
	return st
}
开发者ID:carriercomm,项目名称:repbin,代码行数:9,代码来源:peers.go


示例12: GetSpecificAuth

// GetSpecificAuth fetches a message from a specific server using authentication
func (proto *Proto) GetSpecificAuth(server, auth string, messageID []byte) ([]byte, error) {
	messageIDenc := utils.B58encode(messageID)
	body, err := socks.Proxy(proto.SocksServer).LimitGet(constructURL(server, "/fetch", "?messageid=", messageIDenc, "&auth=", auth), 512000)
	if err != nil {
		return nil, err
	}
	return parseError(body)
}
开发者ID:mewbak,项目名称:repbin,代码行数:9,代码来源:getpost.go


示例13: Encode

// Encode peerstruct into human readable form
func (ps PeerStruct) Encode() PeerStructEncoded {
	out := make([]byte, 0, PeerStructSize)
	out = append(out, []byte(utils.B58encode(ps.AuthToken[:])+" ")...)
	out = append(out, []byte(strconv.FormatUint(ps.LastNotifySend, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ps.LastNotifyFrom, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ps.LastFetch, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ps.ErrorCount, 10)+" ")...)
	out = append(out, []byte(strconv.FormatUint(ps.LastPosition, 10)+" ")...)
	return out[:len(out)]
}
开发者ID:carriercomm,项目名称:repbin,代码行数:11,代码来源:peerstruct.go


示例14: GetGlobalIndex

// GetGlobalIndex returns the global index.
func (ms MessageServer) GetGlobalIndex(w http.ResponseWriter, r *http.Request) {
	var pubKey *message.Curve25519Key
	start := int64(0)
	count := int64(10)
	w.Header().Set("Content-Type", "text/plain; charset=us-ascii")
	getValues := r.URL.Query()
	if getValues != nil {
		if v, ok := getValues["start"]; ok {
			t, err := strconv.Atoi(v[0])
			if err == nil {
				start = int64(t)
			}
		}
		if v, ok := getValues["count"]; ok {
			t, err := strconv.Atoi(v[0])
			if err == nil {
				count = int64(t)
				if count > ms.MaxIndexGlobal {
					count = ms.MaxIndexGlobal
				}
			}
		}
		if v, ok := getValues["auth"]; ok {
			err := ms.AuthenticatePeer(v[0])
			if err != nil {
				io.WriteString(w, fmt.Sprintf("Error: %s", err))
				return
			}
		} else {
			io.WriteString(w, "ERROR: Missing param\n")
			return
		}
	} else {
		io.WriteString(w, "ERROR: Missing param\n")
		return
	}
	messages, found, err := ms.DB.GetGlobalIndex(start, count)
	if err != nil && err != ErrNoMore {
		log.Debugf("List:GetIndex: %s\n", err)
		log.Debugf("List:GetIndex: Key %s\n", utils.B58encode(pubKey[:]))
		io.WriteString(w, "ERROR: List failed\n")
		return
	}
	io.WriteString(w, "SUCCESS: Data follows\n")
	for _, msg := range messages {
		io.WriteString(w, "IDX: "+strings.Trim(string(msg), " \t\n\r")+"\n")
	}
	if int64(found) < count {
		io.WriteString(w, "CMD: Exceeded\n")
	} else {
		io.WriteString(w, "CMD: Continue\n")
	}
}
开发者ID:carriercomm,项目名称:repbin,代码行数:54,代码来源:getglobalindex.go


示例15: Auth

// Auth creates an authentication for server and privKey
func (proto *Proto) Auth(server string, privKey []byte) (string, error) {
	var challenge [keyauth.ChallengeSize]byte
	var secret [keyauth.PrivateKeySize]byte
	info, err := proto.ID(server)
	if err != nil {
		return "", err
	}
	challengeS := utils.B58decode(info.AuthChallenge)
	copy(challenge[:], challengeS)
	copy(secret[:], privKey[:])
	answer := keyauth.Answer(&challenge, &secret)
	return utils.B58encode(answer[:]), nil
}
开发者ID:mewbak,项目名称:repbin,代码行数:14,代码来源:getpost.go


示例16: Fetch

// Fetch returns a single message.
func (ms MessageServer) Fetch(w http.ResponseWriter, r *http.Request) {
	var messageID *[message.MessageIDSize]byte
	w.Header().Set("Content-Type", "text/plain; charset=us-ascii")
	getValues := r.URL.Query()
	if getValues != nil {
		if v, ok := getValues["messageid"]; ok {
			t := utils.B58decode(v[0])
			if len(t) < message.MessageIDSize || len(t) > message.MessageIDSize {
				io.WriteString(w, "ERROR: Bad parameter\n")
				return
			}
			messageID = new([message.MessageIDSize]byte)
			copy(messageID[:], t)
		}
		if ms.HubOnly {
			if v, ok := getValues["auth"]; ok {
				err := ms.AuthenticatePeer(v[0])
				if err != nil {
					io.WriteString(w, fmt.Sprintf("Error: %s", err))
					return
				}
			} else {
				io.WriteString(w, "ERROR: Missing param\n")
				return
			}
		}
	}
	if messageID == nil {
		io.WriteString(w, "ERROR: Missing parameter\n")
		return
	}
	data, err := ms.DB.Fetch(messageID)
	if err != nil {
		log.Debugf("Fetch: %s\n", err)
		io.WriteString(w, "ERROR: No data")
		return
	}
	io.WriteString(w, "SUCCESS: Data follows\n")
	_, err = w.Write(data)
	if err != nil {
		log.Debugf("Write: %s\n", err)
		return
	}
	log.Debugf("Fetch OK: %s\n", utils.B58encode(messageID[:]))
	if ms.Stat {
		stat.Input <- stat.Fetch
	}
	return
}
开发者ID:carriercomm,项目名称:repbin,代码行数:50,代码来源:fetch.go


示例17: CmdGenTempKey

// CmdGenTempKey generates a temporary key for a given private key
func CmdGenTempKey() int {
	var privkey message.Curve25519Key
	privkeystr := selectPrivKey(OptionsVar.Privkey, GlobalConfigVar.PrivateKey, "tty")
	if privkeystr == "" {
		log.Fatal("No private key given (-privkey)")
		return 1
	}
	copy(privkey[:], utils.B58decode(privkeystr))
	pubkey := message.GenPubKey(&privkey)
	privkeytemp, err := message.GenRandomKey()
	if err != nil {
		log.Errorf("Key generation error:%s\n", err)
		return 1
	}
	pubkeytemp := message.GenPubKey(privkeytemp)
	log.Dataf("STATUS (PrivateKey):\t%s_%s\n", utils.B58encode(privkey[:]), utils.B58encode(privkeytemp[:]))
	log.Dataf("STATUS (PublicKey):\t%s_%s\n", utils.B58encode(pubkey[:]), utils.B58encode(pubkeytemp[:]))
	log.Printf("PRIVATE key: %s_%s\n\n", utils.B58encode(privkey[:]), utils.B58encode(privkeytemp[:]))
	log.Printf("Public key: %s_%s\n", utils.B58encode(pubkey[:]), utils.B58encode(pubkeytemp[:]))
	return 0
}
开发者ID:carriercomm,项目名称:repbin,代码行数:22,代码来源:genkey.go


示例18: notifyPeer

func (ms MessageServer) notifyPeer(PubKey *[ed25519.PublicKeySize]byte, url string) {
	rand.Seed(time.Now().UnixNano())
	maxSleep := ms.NotifyDuration - int64(timeout)
	if maxSleep > 0 {
		sleeptime := rand.Int63() % maxSleep
		time.Sleep(time.Duration(sleeptime) * time.Second)
	}
	now := time.Now().Unix() + ms.TimeSkew
	token := utils.B58encode(keyproof.SignProofToken(now, PubKey, ms.TokenPubKey, ms.TokenPrivKey)[:])
	// Socks call
	proto := repproto.New(ms.SocksProxy, "")
	err := proto.Notify(url, token)
	// Write result
	if err != nil {
		log.Debugf("Notify error: %s\n", err)
		ms.DB.UpdatePeerNotification(PubKey, true)
	} else {
		ms.DB.UpdatePeerNotification(PubKey, false)
	}
}
开发者ID:mewbak,项目名称:repbin,代码行数:20,代码来源:notifybackend.go


示例19: Delete

// Delete implements the delete call for messages.
func (ms MessageServer) Delete(w http.ResponseWriter, r *http.Request) {
	var messageID *[message.MessageIDSize]byte
	var privateKey *message.Curve25519Key
	for i := 0; i < 4; i++ {
		ms.RandomSleep() // Let's not give instant gratification here
	}
	w.Header().Set("Content-Type", "text/plain; charset=us-ascii")
	getValues := r.URL.Query()
	if getValues != nil {
		if v, ok := getValues["messageid"]; ok {
			t := utils.B58decode(v[0])
			if len(t) < message.MessageIDSize || len(t) > message.MessageIDSize {
				io.WriteString(w, "ERROR: Bad parameter\n")
				return
			}
			messageID = new([message.MessageIDSize]byte)
			copy(messageID[:], t)
		}
		if v, ok := getValues["privkey"]; ok {
			t := utils.B58decode(v[0])
			if len(t) < message.Curve25519KeySize || len(t) > message.Curve25519KeySize {
				io.WriteString(w, "ERROR: Bad parameter\n")
				return
			}
			privateKey = new(message.Curve25519Key)
			copy(privateKey[:], t)
		}
		if privateKey != nil && messageID != nil {
			publicKey := message.GenPubKey(privateKey)
			err := ms.DB.PreExpire(messageID, publicKey)
			if err == nil {
				log.Errorf("Message censored: %s, asshole.\n", utils.B58encode(messageID[:]))
				io.WriteString(w, "SUCCESS: If you want to call it that\n")
				return
			}
			log.Errorf("Message censoring failed! %s\n", err)
		}
	}
	io.WriteString(w, "ERROR: Missing parameters\n")
	return
}
开发者ID:carriercomm,项目名称:repbin,代码行数:42,代码来源:delete.go


示例20: ListSpecific

// ListSpecific lists the messages for pubKey from a specific server
func (proto *Proto) ListSpecific(server string, pubKey, privKey []byte, start, count int) (messages []*structs.MessageStruct, more bool, err error) {
	var authStr string
	var myPubKey message.Curve25519Key
	copy(myPubKey[:], pubKey)
	if message.KeyIsHidden(&myPubKey) {
		if privKey == nil {
			return nil, false, ErrPrivKey
		}
		auth, err := proto.Auth(server, privKey)
		if err != nil {
			return nil, false, err
		}
		authStr = "&auth=" + auth
	}
	url := constructURL(server, "/keyindex?key=", utils.B58encode(pubKey[:]), "&start=", strconv.Itoa(start), "count=", strconv.Itoa(count), authStr)
	body, err := socks.Proxy(proto.SocksServer).LimitGet(url, 512000)
	if err != nil {
		return nil, false, err
	}
	return parseListResponse(body)
}
开发者ID:mewbak,项目名称:repbin,代码行数:22,代码来源:getpost.go



注:本文中的github.com/repbin/repbin/utils.B58encode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang integram.Context类代码示例发布时间:2022-05-28
下一篇:
Golang utils.B58decode函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap