1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Vue.jsで文字列をBase64に変換する方法

Posted at

概要

  • Fitbitのアクセストークンを更新する際に client_id:client secret をBase64に変換する必要があったので、やり方を備忘録として残します。

Fitbitの公式ドキュメント
Fitbit Developer - Refresh Token

環境

Windows10
Vue.js 3

やり方

1. ターミナルでnpm install

powershell
npm install buffer

2. 変換コード

Sample.vue
import { Buffer } from 'buffer'

// base64にエンコード
const beforeText = "HogeTaro:example"
const afterText = Buffer.from(beforeText).toString('base64')
console.log("beforeText -> "+beforeText)
console.log("afterText -> "+afterText)
実行結果
beforeText -> HogeTaro:example
afterText -> SG9nZVRhcm86ZXhhbXBsZQ==

参考

このサイトで変換結果が正しいか検証可能です
base64エンコード/デコードツール

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?