# AccountID to Principal

**URL:** <https://forum.dfinity.org/t/accountid-to-principal/7564>\
**Category:** Developers\
**Tags:** Functional-Programming\
**Created:** [September 26, 2021, 2:02pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564 "2021-09-26T14:02:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gladguy](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gladguy/32/11145_2.png) [@gladguy](https://forum.dfinity.org/u/gladguy)\
**Post date:** [September 26, 2021, 2:02pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564/1 "2021-09-26T14:02:46Z")

</div>

Hello Developers,

Wondering is there any way to convert Account ID to Principal

I am aware that we can generate from Principal we can generate account ID.

How we do in reverse ? Account ID to Principal

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![dpdp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dpdp/32/1143_2.png) [@dpdp](https://forum.dfinity.org/u/dpdp)\
**Post date:** [September 26, 2021, 2:06pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564/2 "2021-09-26T14:06:15Z")

</div>

It uses Sha224 so **unlikely** and that’s why it has been created at the first place I guess (and the ability to create SubAccount);

> <https://github.com/dfinity/ic/blob/master/rs/rosetta-api/ledger_canister/src/account_identifier.rs#L45>

---

<div class="post-metadata">

**Author:** ![gladguy](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gladguy/32/11145_2.png) [@gladguy](https://forum.dfinity.org/u/gladguy)\
**Post date:** [September 26, 2021, 2:10pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564/3 "2021-09-26T14:10:45Z")

</div>

Thank you will try.

Is the convert the account id to principal back ?

Is it possible to derive Principal from Account-ID

---

<div class="post-metadata">

**Author:** ![dpdp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dpdp/32/1143_2.png) [@dpdp](https://forum.dfinity.org/u/dpdp)\
**Post date:** [September 26, 2021, 2:12pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564/4 "2021-09-26T14:12:23Z")

</div>

I don’t think so – unfortunately.

---

<div class="post-metadata">

**Author:** ![Hic](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/hic/32/5689_2.png) [@Hic](https://forum.dfinity.org/u/Hic)\
**Post date:** [May 20, 2022, 1:41pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564/5 "2022-05-20T13:41:04Z")

</div>

I’ve been going down this rabbit hole lately and would like to wrap my mind around the problem, so forgive me if this is a stupid question:

Is this because it is not possible / intentionally too cryptographically difficult to hash in reverse or is this because no one has spent the time to implement it?

---

<div class="post-metadata">

**Author:** ![bogwar](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bogwar/32/2161_2.png) [@bogwar](https://forum.dfinity.org/u/bogwar)\
**Post date:** [May 20, 2022, 1:55pm UTC](https://forum.dfinity.org/t/accountid-to-principal/7564/6 "2022-05-20T13:55:57Z")

</div>

Hi @Hic

In general, it is computationally difficult to invert a good cryptographic hash function like the one used to compute account ids (out of principals and subaccount id)
