> For the complete documentation index, see [llms.txt](https://www.pentestwiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pentestwiki.com/data-theft/file-transper/base64.md).

# Base64

{% tabs %}
{% tab title="Windows -> UNIX" %}

<pre class="language-powershell"><code class="lang-powershell"><strong># 원본 파일 해쉬 계산
</strong>Get-FileHash id_rsa -Algolithm md5

<strong># Case 1. PowerShell을 통한 Base64 파일 생성
</strong>[Convert]::ToBase64String((Get-Content -Path id_rsa -Encoding byte)) > id_rsa.base64

<strong># Case 2. certutil을 통한 Base64 파일 생성
</strong>certutil -encode id_rsa id_rsa.base64
</code></pre>

Base64 인코딩 문자를 복사한 뒤  Linux에서 Base64 디코딩 후 파일로 저장합니다.

<pre class="language-bash"><code class="lang-bash"><strong># Base64 문자열을 디코딩하여 파일로 저장
</strong>echo &#x3C;Base64 Encoded String> | base64 -d > id_rsa

<strong># 해시 계산을 통한 무결성 검증
</strong>md5sum id_rsa
</code></pre>

{% endtab %}

{% tab title="UNIX -> Windows" %}

<pre class="language-bash"><code class="lang-bash"><strong># 원본 파일 해쉬 계산
</strong>md5sum id_rsa                        

<strong># 원본 파일 Base64 인코딩
</strong>cat id_rsa | base64 -w 0; echo
</code></pre>

결과로 나오는 Base64 인코딩을 복사한 뒤 Windows에서 객체를 생성하여 파일로 변환합니다.

<pre class="language-powershell"><code class="lang-powershell"><strong># Base64로 인코딩된 문자열 변수에 저장
</strong>$base64String = &#x3C;Base64 Encoded String>

<strong># Base64 문자열을 디코딩하여 바이트 배열로 변환
</strong>$byteArray = [Convert]::[FromBase64String($base64String)

<strong># 바이트 배열을 파일로 저장
</strong>[System.IO.File]::WriteAllBytes('id_rsa', $byteArray)

# 해시 계산을 통한 무결성 검증
Get-FileHash id_rsa -Algolithm md5
</code></pre>

{% endtab %}
{% endtabs %}
